package components.base
{
	import mx.core.IFlexDisplayObject;
	import mx.events.FlexEvent;
	
	import spark.components.RadioButton;
	import spark.components.RadioButtonGroup;
	
	public class BaseRadioButtonGroup extends RadioButtonGroup
	{
		public function BaseRadioButtonGroup(document:IFlexDisplayObject=null)
		{
			super(document);
		}
		//是否已有ChangeWatcher监听其属性更改
		public var isWatching:Boolean;
		
		[Bindable("change")]
		[Bindable("valueCommit")]
		[Inspectable(category="General")]
		public function set value(p_value:String):void
		{
			var num:int = this.numRadioButtons;
			for (var index:int = 0; index < num; index++)
			{
				var radio:RadioButton = this.getRadioButtonAt(index) as RadioButton;
				if (radio.value == p_value)
				{
					radio.selected = true;
					break;
				}
			}
			dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
		}
		public function get value():String
		{
			var num:int = this.numRadioButtons;
			for (var index:int = 0; index < num; index++)
			{
				var radio:RadioButton = this.getRadioButtonAt(index) as RadioButton;
				if (radio.selected)
				{
					return radio.value.toString();
				}
			}
			return null;
		}
	}
}